<?php
/**
 * Created by PhpStorm.
 * User: ljc
 * Date: 2018/8/6
 * Time: 16:17
 */

namespace Modules\Mall\Service;

use Blade;
class TagService
{
	public function make(){
		$this->article();
	}
	public function article(){
        Blade::directive('article',function ($canshu){
        $canshu = $canshu ?: '[]';
        //定义定界符的字符串
            $php = <<<php
<?php
\$params = $canshu;
\$db = (new \Modules\Mall\Entities\Mall())->where('status',1);
if(isset(\$params['orderBy'])){
	\$db = \$db->orderBy(\$params['orderBy'],'desc');
}
if(isset(\$params['skip'])){
    \$db = \$db->skip(\$params['skip']);
}
if(isset(\$params['take'])){
	\$db = \$db->take(\$params['take']);
}
\$art = \$db->get();
foreach(\$art as \$a){

?>
php;
        return $php;
        });

        Blade::directive('endarticle',function (){
            //定义定界符的字符串
            $php = <<<php
<?php
}
?>
php;
            return $php;
        });
    }
}